package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.Travel;
import cn.wolfcode.trip.base.query.TravelObject;
import cn.wolfcode.trip.base.service.ITravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("travelRelease")
public class TravelReleaseController {
    @Autowired
    private ITravelService travelService;

    @RequestMapping("list")
    public String list(Model model, @ModelAttribute("qo") TravelObject qo){
        System.out.println(qo);
        qo.setState(Travel.STATE_RELEASE);
        //在qo中添加一个属性  用来查询是否是热门
        qo.setHot(Travel.STATE_HOT);
        //取消热门后的发布状态
        qo.setRelease(Travel.STATE_RELEASE2);
        qo.setIsPublic(true);
        qo.setOrderBy("t.createTime desc");
        model.addAttribute("pageInfo",travelService.query(qo));
        return "travel/list";
    }
}
